/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.kj.member.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.sys.entity.Area;
import com.jeesite.modules.sys.entity.Company;
import com.jeesite.modules.sys.entity.Office;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * kj_sys_memberEntity
 * @author hzy
 * @version 2019-09-06
 */
@Table(name="kj_sys_member", alias="a", columns={
		@Column(name="member_code", attrName="memberCode", label="会员编码", isPK=true),
		@Column(name="member_name", attrName="memberName", label="会员名", queryType=QueryType.LIKE),
		@Column(name="member_nickname", attrName="memberNickname", label="会员昵称"),
		@Column(includeEntity=DataEntity.class),
		@Column(name="office_code", attrName="office.officeCode", 	label="机构编码", isQuery=false),
		@Column(name="office_name", attrName="office.officeName", 	label="机构名称", isQuery=false),
		@Column(name="company_code", attrName="company.companyCode", label="公司编码", isQuery=false),
		@Column(name="company_name", attrName="company.companyName", label="公司名称", isQuery=false),
		@Column(name="idcard", attrName="idcard", label="身份证号"),
		@Column(name="level", attrName="level", label="会员等级"),
		@Column(name="integrals", attrName="integrals", label="总积分"),
		@Column(name="hours", attrName="hours", label="总工时"),
		@Column(name="work", attrName="work", label="工作"),
		@Column(name="home_address", attrName="homeAddress", label="家庭住址"),
		@Column(name="birthday", attrName="birthday", label="生日"),
	}, joinTable={
		@JoinTable(type=JoinTable.Type.LEFT_JOIN, entity=Office.class, alias="o",
				on="o.office_code = a.office_code",
				columns={@Column(includeEntity=Office.class)}),
		@JoinTable(type=JoinTable.Type.LEFT_JOIN, entity=Company.class, alias="c",
				on="c.company_code = a.company_code",
				columns={@Column(includeEntity=Company.class)}),
		@JoinTable(type=JoinTable.Type.LEFT_JOIN, entity=Area.class, alias="ar",
				on="ar.area_code = c.area_code", attrName="company.area",
				columns={
						@Column(name="area_name", label="区域名称"),
						@Column(name="area_type", label="区域类型"),
				}),
}, orderBy="a.update_date DESC"
)
public class Member extends DataEntity<Member> {
	
	private static final long serialVersionUID = 1L;
	private String memberCode;		// 会员编码
	private String memberName;		// 会员名
	private String memberNickname;		// 会员昵称
//	private String companyCode;		// 所属公司
//	private String companyName;		// 公司名
//	private String officeCode;		// 所属机构
//	private String officeName;		// 机构名
	private String idcard;		// 身份证号
	private Long level;		// 会员等级
	private String work;		// 工作
	private String homeAddress;		// 家庭住址
	private Date birthday;		// 生日

	private Office office;		// 机构编码
	private Company company;	// 公司编码
	
	public Member() {
		this(null);
	}

	public Member(String id){
		super(id);
	}
	
	public String getMemberCode() {
		return memberCode;
	}

	public void setMemberCode(String memberCode) {
		this.memberCode = memberCode;
	}
	
	@NotBlank(message="会员名不能为空")
	@Length(min=0, max=255, message="会员名长度不能超过 255 个字符")
	public String getMemberName() {
		return memberName;
	}

	public void setMemberName(String memberName) {
		this.memberName = memberName;
	}
	
	@Length(min=0, max=255, message="会员昵称长度不能超过 255 个字符")
	public String getMemberNickname() {
		return memberNickname;
	}

	public void setMemberNickname(String memberNickname) {
		this.memberNickname = memberNickname;
	}
//
//	@Length(min=0, max=64, message="所属公司长度不能超过 64 个字符")
//	public String getCompanyCode() {
//		return companyCode;
//	}
//
//	public void setCompanyCode(String companyCode) {
//		this.companyCode = companyCode;
//	}
//
//	@Length(min=0, max=255, message="公司名长度不能超过 255 个字符")
//	public String getCompanyName() {
//		return companyName;
//	}
//
//	public void setCompanyName(String companyName) {
//		this.companyName = companyName;
//	}
//
//	public String getOfficeCode() {
//		return officeCode;
//	}
//	@Length(min=0, max=64, message="所属机构长度不能超过 64 个字符")
//	public void setOfficeCode(String officeCode) {
//		this.officeCode = officeCode;
//	}
//
//	public String getOfficeName() {
//		return officeName;
//	}
//	@Length(min=0, max=255, message="机构名长度不能超过 255 个字符")
//	public void setOfficeName(String officeName) {
//		this.officeName = officeName;
//	}

	//	@NotBlank(message="身份证号不能为空")
	@Length(min=0, max=255, message="身份证号长度不能超过 255 个字符")
	public String getIdcard() {
		return idcard;
	}

	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	
	public Long getLevel() {
		return level;
	}

	public void setLevel(Long level) {
		this.level = level;
	}

	
	@Length(min=0, max=255, message="工作长度不能超过 255 个字符")
	public String getWork() {
		return work;
	}

	public void setWork(String work) {
		this.work = work;
	}
	
	@Length(min=0, max=255, message="家庭住址长度不能超过 255 个字符")
	public String getHomeAddress() {
		return homeAddress;
	}

	public void setHomeAddress(String homeAddress) {
		this.homeAddress = homeAddress;
	}

	public Date getBirthday() {
		return birthday;
	}

	@JsonFormat(pattern = "yyyy-MM-dd")
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}


	@NotNull(message="归属机构不能为空")
	public Office getOffice() {
		if (office == null){
			office = new Office();
		}
		return office;
	}

	public void setOffice(Office office) {
		this.office = office;
	}

	@NotNull(message="归属公司不能为空")
	public Company getCompany() {
		if (company == null){
			company = new Company();
		}
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

}